home *** CD-ROM | disk | FTP | other *** search
- /* Listing 16.26 Shader mapping object-space coordinates to colors*/
- /*
- * glow(): a shader for providing a centered "glow" in a sphere
- */
-
- surface
- RCGlow( float attenuation = 2 )
- {
- point NN = normalize(N);
- point II = normalize(I);
- float falloff = II.NN; /* Direct incidence has cosine closer to 1.*/
-
- if (falloff < 0)
- { /* Back of sphere only */
- /* Normalize falloff by lengths of I and N */
- falloff = falloff * falloff / (II.II * NN.NN) ;
- falloff = pow(falloff, attenuation);
- Ci = Cs * falloff;
- Oi = falloff;
- }
- else
- { Oi = 0;
- Ci = 0; /* wave added this line to avoid old bug in rendrib... */
- }
- }
-